package com.le.tester.book.concurrentchallenge.threadSafedelegation;

/**
 * createTime：2025-03-17 10:03
 * description：线程安全point
 */
public class SafePoint {
    private int x, y;

    private SafePoint(int[] a) {
        this(a[0], a[1]);
    }

    public SafePoint(SafePoint p) {
        this(p.get());
    }

    private synchronized int[] get() {
        return new int[]{x, y};
    }

    public SafePoint(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public synchronized void set(int x, int y) {
        this.x = x;
        this.y = y;
    }

}
